home *** CD-ROM | disk | FTP | other *** search
-
- #include "cb.h"
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int cmp_node();
- caddr_t mc;
- caddr_t mi;
- caddr_t end;
- struct stat st;
- struct nind *idx;
- struct nind key;
- struct nind *found;
- int dir;
- long p;
- long idsize;
- int nel;
- FILE *fp;
-
- int IS = sizeof(struct nind);
-
- if ((fp=fopen("nlist.ndx","r+")) == NULL)
- {
- printf("Error opening nlist.ndx\n");
- exit(1);
- }
- fstat(fileno(fp),&st);
- if ((mi = (caddr_t)mmap(NULL,st.st_size,PROT_READ|PROT_WRITE,MAP_SHARED,
- fileno(fp),NULL)) == (caddr_t)NULL)
- {
- fprintf(stderr,"Error - mmap index file\n");
- exit(1);
- }
- fclose(fp);
-
- idsize = st.st_size/IS;
- idx = (struct nind *)mi;
-
- qsort((char *)idx, idsize, sizeof(struct nind), cmp_node);
-
- munmap(mi,st.st_size);
-
- exit(0);
-
- }
-
- cmp_node(i1,i2)
- struct nind *i1, *i2;
- {
- return(strcmp(i1->name,i2->name));
- }
-
-